<?php

namespace app\api\controller;

use app\common\controller\Logined;


use think\Db;

class Community extends Logined {

	public function _initialize() {
		header("Access-Control-Allow-Origin: *");
		parent::_initialize();
	}

	/*
	应用列表
	*/
	public function appList() {
		$amount = P('amount');
		$type   = P('type')?:1;
		if (empty($amount) || empty($type)) {
			$data= Db::table('tp_community_application')->where('type',$type)->select();
		} else {
			$data= Db::table('tp_community_application')->where('type',$type)->limit($amount)->select();
		}
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}

	/*
	 通稿
	 */
	public function announce() {
		$data = Db::table('tp_community_announce')->order('id desc')->select();
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}

	
	/*
	通稿详情
	 */
	public function announceDetail() {
		$id   = P('id');
		if(empty($id)){
			$this->retData(1, '缺少参数');
		}
		$data = Db::table('tp_community_announce')->where('id', $id)->find();
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}

	/*
	轮播图
	 */
	public function getSlideshow() {
	
		$data = Db::table('tp_community_slideshow')->where('status', 1)->select();
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}

}
